//TODO 对称加密
//blowfish算法是一种对称的加密算法,对称的意思就是加密和解密使用的是同一个密钥。

/*const crypto = require('crypto');
const path = require('path');
const fs = require('fs');
const resolve = filepath => path.join(__dirname, filepath);
const key = fs.readFileSync(resolve('rsa_private.key'));

const str = 'nihaoshiki';
const cipher = crypto.createCipher('blowfish',key);
cipher.update(str, 'utf8'/!*要加密的内容以什么编码方式写入*!/);
const r = cipher.final('hex'/!*以怎样的编码展示加密后的内容*!/);
console.log('r:',r);

const deciper = crypto.createDecipher('blowfish', key);
deciper.update(r, 'hex');
console.log(deciper.final('utf8'));*/



//↑的str里的长度貌似是有限制的
//↓这样写没有限制


const path = require('path');
var crypto = require('crypto');
var fs = require('fs');
let str = 'ni好,shiki!';
let cipher = crypto.createCipher('blowfish', fs.readFileSync(path.join(__dirname, 'rsa_private.key')));
let encry = cipher.update(str, 'utf8','hex');
encry += cipher.final('hex');
console.log(encry);

let deciper = crypto.createDecipher('blowfish', fs.readFileSync(path.join(__dirname, 'rsa_private.key')));
let deEncry = deciper.update(encry, 'hex','utf8');
deEncry += deciper.final('utf8');
console.log(deEncry);
